<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>删除表格中的行</title>
</head>

<body>
    <table id="myTable" border="1">
        <tr>
            <td>行 1</td>
            <td><input type="button" value="删除" onclick="deleteRow(this)"></td>
        </tr>
        <tr>
            <td>行 2</td>
            <td><input type="button" value="删除" onclick="deleteRow(this)"></td>
        </tr>
        <tr>
            <td>行 3</td>
            <td><input type="button" value="删除" onclick="deleteRow(this)"></td>
        </tr>
    </table>
    <script>
        function deleteRow(r) {
            var i = r.parentNode.parentNode.rowIndex;
            document.getElementById('myTable').deleteRow(i);
        }
    </script>
</body>

</html>